<?php
class myInterator implements \Iterator{
    private $postion=0;
    private $arr=[
        "sgha","ajsjs","dkjl","ioeoe","oaoa"
    ];

    public function current(){
        var_dump(__CLASS__."/".__METHOD__);
        return $this->arr[$this->postion];
    }

    public function key(){
        var_dump(__CLASS__."/".__METHOD__);
        return $this->postion;
    }

    public function next(){
        var_dump(__CLASS__."/".__METHOD__);
        $this->postion++;
    }

    public function rewind(){
        var_dump(__CLASS__."/".__METHOD__);
        $this->postion=0;
    }

    public function valid(){
        var_dump(__CLASS__."/".__METHOD__);
        return isset($this->arr[$this->postion]);
    }
}

function myErrorHandler($errno,$errmsg,$errfile,$errline,$errcontext){
    echo($errmsg.$errfile.$errline."<br/>");
}

set_error_handler("myErrorHandler",E_USER_ERROR);
trigger_error("aaaa",E_USER_ERROR);

function myExceptionHandler($ex){
    echo "exception: ".$ex->getMessage().$ex->getFile().$ex->getCode()."<br/>";
}

set_exception_handler("myExceptionHandler");

//throw new Exception("exception",500);



$iterator=new myInterator();
var_dump($iterator);
foreach ($iterator as $key =>$value){
    var_dump($key, $value);
    echo "\n";
}